package com.mornd.gulimall.product.web.v1;

import com.mornd.gulimall.product.entity.vo.skuitem.SkuItemResult;
import com.mornd.gulimall.product.service.ISkuInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

/**
 * @author: mornd
 * @dateTime: 2023/8/16 - 12:49
 */

@Slf4j
@Controller
public class ItemController {
    @Resource
    private ISkuInfoService skuInfoService;

    /**
     * sku 详情
     *
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String itemPage(@PathVariable(name = "skuId") Long skuId, Model model) {
        SkuItemResult result = new SkuItemResult();
        try {
            result = skuInfoService.item(skuId);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        model.addAttribute("result", result);
        return "item";
    }
}
